/**
 * 
 */
package com.fdl.dao.base.impl;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 * 过滤条件转换成criteria 
 * @project: hb-intra
 * @Date:2010-7-29
 * @version  1.0
 * @Company: 33e9
 * @author zhangYong.huang
 */
public class CriteriaSetup {
	public void setup(Criteria criteria, Map filter) {
		if (filter != null && !filter.isEmpty()) {
			Set keys = filter.keySet();
			Iterator iterator = keys.iterator();
			while (iterator.hasNext()) {
				String key = (String) iterator.next();
				Object value = filter.get(key);
				if (value != null)
					criteria.add(Restrictions.eq(key, value));
			}
		}
	}
}
